<script setup lang="ts">
import ReCol from "@/components/ReCol";
import { ref } from "vue";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";
import Segmented from "@/components/ReSegmented";
import {usePublicHooks} from "@/views/system/hooks";
import SplitPane from "@/components/ReSplitPane";
const { switchStyle } = usePublicHooks();

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    id: 0,
    state: "",
    name: "",
    commission: 1,
    commission1: 1,
    status: 1,
  }),
  userList:()=>([])
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);
const newFormuserList = ref(props.userList);
function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });

</script>

<template>

  <el-form ref="ruleFormRef" size="small" :model="newFormInline" :rules="formRules" label-width="120px">
    <el-row :gutter="30">
      <re-col :value="24" :xs="24" :sm="24">
        <el-form-item label="采购姓名" prop="user_id">
          <el-select v-model="newFormInline.user_id"
            placeholder="采购姓名" class="!w-full" clearable filterable>
            <el-option class="w-full"  v-for="(item, index) in props.userList" :key="index" :label="item.nickname" :value="item.id" />
          </el-select>
        </el-form-item>
      </re-col>

      <re-col :value="24" :xs="24" :sm="24">
        <el-form-item label="编号前缀" prop="prefix_no">
          <el-input v-model="newFormInline.prefix_no" clearable placeholder="请输入编号前缀"/>
        </el-form-item>
      </re-col>

      <re-col :value="24" :xs="24" :sm="24">
        <el-form-item label="新报价提成金额" prop="commission">
          <el-input-number v-model="newFormInline.commission" class="!w-full" clearable placeholder="新报价单笔提成金额" :min="1" :step="1" controls-position="right" >
            <template #prepend>元</template>
          </el-input-number>
        </el-form-item>
      </re-col>
      <re-col :value="24" :xs="24" :sm="24">
        <el-form-item label="重新报价提成金额" prop="commission1">
          <el-input-number v-model="newFormInline.commission1" class="!w-full" clearable placeholder="重新报价单笔提成金额" :min="1" :step="1" controls-position="right" >
            <template #prepend>元</template>
          </el-input-number>
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="每日接单上限" prop="limit_upper">
          <el-input-number v-model="newFormInline.limit_upper" clearable placeholder="每日接单上限" :min="1" :step="1" controls-position="right" />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <span></span>
      </re-col>
      <re-col :value="24" :xs="24" :sm="24">
        <el-form-item label="状态">
          <el-switch v-model="newFormInline.status" inline-prompt :active-value="1"
                     :inactive-value="0" active-text="启用" inactive-text="停用" :style="switchStyle"/>
        </el-form-item>
      </re-col>
    </el-row>
  </el-form>

</template>
